package com.dingreading.cloud.admin.util.bean;

import com.dingreading.cloud.admin.entity.SubjectLesson;
import com.dingreading.cloud.admin.entity.Subjects;
import com.dingreading.cloud.common.util.KitUtil;

public class SubjectUtil {

    public static Subjects newMainSubject(String subjectName, Integer showOrder, String cooperationType) {
        Subjects subjects = new Subjects();
        subjects.setUid(KitUtil.getUuid());
        subjects.setSubjectName(subjectName);
        subjects.setSubjectDescribe("");
        subjects.setSubjectOrder(0);
        subjects.setShowOrder(showOrder);
        subjects.setParentId(0L);
        subjects.setLevelEnd(0);
        subjects.setLessonNum(0);
        subjects.setLevelName("学科");
        subjects.setLevelIndex(0);
        subjects.setSelfStore(1);
        subjects.setFreeStatus(1);
        subjects.setEnabled(1);
        subjects.setCooperationType(cooperationType);
        return subjects;
    }

    public static Subjects newChildSubject(
            Long id, Long subjectMainId, Long parentId, String subjectName, String subjectDescribe,
            Integer maxSubjectOrder, String levelName, Integer levelEnd, Integer lessonNum,
            Integer levelIndex, Integer freeStatus
    ) {
        Subjects subjects = new Subjects();
        if (id != null && id > 0)
            subjects.setId(id);
        subjects.setUid(KitUtil.getUuid());
        subjects.setSubjectName(subjectName);
        subjects.setSubjectMainId(subjectMainId);
        subjects.setSubjectOrder(maxSubjectOrder);
        subjects.setParentId(parentId);
        subjects.setLevelName(levelName);
        subjects.setLevelEnd(levelEnd);
        subjects.setFreeStatus(freeStatus);
        if (lessonNum != null)
            subjects.setLessonNum(lessonNum);
        if (subjectDescribe != null)
            subjects.setSubjectDescribe(subjectDescribe);
        if (levelIndex != null)
            subjects.setLevelIndex(levelIndex);
        subjects.setSelfStore(1);
        subjects.setEnabled(1);
        return subjects;
    }

    public static Subjects editChildSubject(
            Subjects subjects, String subjectName, String subjectDescribe, String levelName
    ) {
        if (subjectName != null)
            subjects.setSubjectName(subjectName);
        if (levelName != null)
            subjects.setLevelName(levelName);
        if (subjectDescribe != null)
            subjects.setSubjectDescribe(subjectDescribe);
        return subjects;
    }

    public static SubjectLesson newLesson(
            Long subjectMainId, String subjectMainName, Long subjectId, Integer lessonOrder, String nodes
    ) {
        SubjectLesson lesson = new SubjectLesson();
        lesson.setSubjectMainId(subjectMainId);
        lesson.setSubjectMainName(subjectMainName);
        lesson.setSubjectId(subjectId);
        lesson.setLessonOrder(lessonOrder);
        lesson.setUid(KitUtil.getUuid());
        lesson.setEnabled(1);
        lesson.setDownloadNum(0);
        lesson.setSubjectNodes(nodes);
        return lesson;
    }

}
